# coding:utf-8

import pymysql

db = pymysql.connect("localhost", "root", "boyun2017", "py_mysql")
cursor = db.cursor()
sql = """SELECT * FROM employee
         WHERE income > '%d'""" % 100
try:
    cursor.execute(sql)
    results = cursor.fetchall()
    for row in results:
        first_name = row[0]
        last_name = row[1]
        age = row[2]
        sex = row[3]
        income = row[4]
        print("first_name=%s,last_name=%s,age=%d,sex=%s,income=%d" %
              (first_name, last_name, age, sex, income))
except:
    print("Error:unable to fetch data")

db.close()
